<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // const p = new Promise((resolve, reject) => {
      //   setTimeout(() => {
      //     reject("err");
      //   }, 3000);
      // })
      //   .then(() => {})
      //   .catch(() => {});
      //promise返回失败的实例 如果未经catch捕获处理 贼会在控制台输出报错信息
        
      //封装一个函数模拟push
      function push(location, onComplete, onAbort) {
        return new Promise((resolve, reject) => {
          setTimeout(() => {
            reject("err");
          }, 3000);
        })
          .then(onComplete)
          .catch(onAbort);
      }

      function MyPush(L, onComplete = () => {}, onAbort = () => {}) {
        return push(L, onComplete, onAbort);
      }
      MyPush("1");
    </script>
  </body>
</html>
